Effect of UPSTM-Based
Decorrelation on Feature Discovery
Loading the
libraries
library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
library(TH.data)
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
Material and
Methods
About Dataset Coronaviruses are a broad family of viruses that have
been linked to illnesses ranging from the common cold to more serious
conditions such as Middle East Respiratory Syndrome (MERS) and Severe
Acute Respiratory Syndrome (SARS) (SARS. In 2019, a new coronavirus
(COVID-19) was discovered in Wuhan, China.
Sometimes, When PCR test resources are scarce and antigen test kits
are inaccurate, clinicians look for alternate COVID-19 testing methods
that can be completed in a day and handle thousands of samples. COVID-19
virus proteins should be lacking in normal people’s saliva. Some
distinct proteins may be produced in response to COVID-19 infection and
can be utilized as a signature to identify potentially infected people.
Therefore, protein profiles in a patient’s saliva can indicate that he
or she is infected with COVID-19.
Mass spectrometry is a method for determining the protein composition
of a material. Saliva samples from hundreds of patients were studied in
this dataset. So, a machine learning specialist is approached and
charged with developing a machine learning model that can identify who
COVID-19 infected since the PCR test cannot interpret the result
completely.
The Data
https://www.kaggle.com/datasets/kerneler/saliva-testing-dataset?select=COVID-19_MS_dataset_train.csv
COVID_19_MS <- read.csv("~/GitHub/LatentBiomarkers/Data/COVID19_MS/COVID-19_MS_dataset_train.csv")
colnames(COVID_19_MS) <- str_replace_all(colnames(COVID_19_MS),"\\.","_")
COVID_19_MS$Person_ID <- NULL
sampleID <- unique(COVID_19_MS$Sample_ID)
spectraID <- colnames(COVID_19_MS)[str_detect(colnames(COVID_19_MS),"X")]
avgCOVID19 <- NULL
class <- COVID_19_MS[!duplicated(COVID_19_MS$Sample_ID),"PCR_result"]
for (id in sampleID)
{
avgCOVID19 <- rbind(avgCOVID19,apply(COVID_19_MS[COVID_19_MS$Sample_ID %in% id,spectraID],2,mean))
}
avgCOVID19 <- as.data.frame(avgCOVID19)
rownames(avgCOVID19) <- sampleID
avgCOVID19$class <- 1*(class=="pos")
pander::pander(table(avgCOVID19$class))
Standarize the
names for the reporting
studyName <- "COVID19_MS"
dataframe <- avgCOVID19
outcome <- "class"
thro <- 0.80
TopVariables <- 10
cexheat = 0.25
Generaring the
report
Libraries
Some libraries
library(psych)
library(whitening)
library("vioplot")
library("rpart")
Data specs
pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
pander::pander(table(dataframe[,outcome]))
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
largeSet <- length(varlist) > 1500
Scaling the
data
Scaling and removing near zero variance columns and highly
co-linear(r>0.99999) columns
### Some global cleaning
sdiszero <- apply(dataframe,2,sd) > 1.0e-16
dataframe <- dataframe[,sdiszero]
varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
dataframe <- dataframe[,tokeep]
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
iscontinous <- sapply(apply(dataframe,2,unique),length) >= 5 ## Only variables with enough samples
dataframeScaled <- FRESAScale(dataframe,method="OrderLogit")$scaledData
The heatmap of the
data
numsub <- nrow(dataframe)
if (numsub > 1000) numsub <- 1000
if (!largeSet)
{
hm <- heatMaps(data=dataframeScaled[1:numsub,],
Outcome=outcome,
Scale=TRUE,
hCluster = "row",
xlab="Feature",
ylab="Sample",
srtCol=45,
srtRow=45,
cexCol=cexheat,
cexRow=cexheat
)
par(op)
}
Correlation
Matrix of the Data
The heat map of the data
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
#cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
cormat <- cor(dataframe[,varlist],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Original Correlation",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
diag(cormat) <- 0
print(max(abs(cormat)))
}
The
decorrelation
DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#>
#> Included: 2328 , Uni p: 0.004316151 , Uncorrelated Base: 1297 , Outcome-Driven Size: 0 , Base Size: 1297
#>
#>
1 <R=0.994,thr=0.900,N= 115>, Top: 28( 1 )[ 1 : 28 Fa= 28 : 0.900 ]( 28 , 55 , 0 ),<|>Tot Used: 83 , Added: 55 , Zero Std: 0 , Max Cor: 0.975
#>
2 <R=0.975,thr=0.900,N= 115>, Top: 6( 5 )[ 1 : 6 Fa= 34 : 0.900 ]( 6 , 20 , 28 ),<|>Tot Used: 107 , Added: 20 , Zero Std: 0 , Max Cor: 0.949
#>
3 <R=0.949,thr=0.900,N= 115>, Top: 1( 1 )[ 1 : 1 Fa= 35 : 0.900 ]( 1 , 1 , 34 ),<|>Tot Used: 109 , Added: 1 , Zero Std: 0 , Max Cor: 0.900
#>
4 <R=0.900,thr=0.800,N= 238>, Top: 66( 1 )[ 1 : 66 Fa= 84 : 0.800 ]( 66 , 117 , 35 ),<|>Tot Used: 262 , Added: 117 , Zero Std: 0 , Max Cor: 0.907
#>
5 <R=0.907,thr=0.900,N= 2>, Top: 1( 1 )[ 1 : 1 Fa= 85 : 0.900 ]( 1 , 1 , 84 ),<|>Tot Used: 262 , Added: 1 , Zero Std: 0 , Max Cor: 0.885
#>
6 <R=0.885,thr=0.800,N= 30>, Top: 10( 1 )[ 1 : 10 Fa= 92 : 0.800 ]( 10 , 16 , 85 ),<|>Tot Used: 282 , Added: 16 , Zero Std: 0 , Max Cor: 0.813
#>
7 <R=0.813,thr=0.800,N= 30>, Top: 1( 1 )[ 1 : 1 Fa= 93 : 0.800 ]( 1 , 1 , 92 ),<|>Tot Used: 284 , Added: 1 , Zero Std: 0 , Max Cor: 0.800
#>
8 <R=0.800,thr=0.800,N= 30>
#>
[ 8 ], 0.7981248 Decor Dimension: 284 Nused: 284 . Cor to Base: 177 , ABase: 29 , Outcome Base: 0
#>
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]
pander::pander(sum(apply(dataframe[,varlist],2,var)))
23332
pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))
5390
pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))
0.132
pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))
0.241
The decorrelation
matrix
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
UPSTM <- attr(DEdataframe,"UPSTM")
gplots::heatmap.2(1.0*(abs(UPSTM)>0),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
}
The correlation
matrix after decorrelation
if (!largeSet)
{
cormat <- cor(DEdataframe[,varlistc],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Correlation after IDeA",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
par(op)
diag(cormat) <- 0
print(max(abs(cormat)))
}
U-MAP Visualization
of features
The UMAP based on
LASSO on Raw Data
if (nrow(dataframe) < 1000)
{
classes <- unique(dataframe[1:numsub,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
datasetframe.umap = umap(scale(dataframe[1:numsub,varlist]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[1:numsub,outcome],col=raincolors[dataframe[1:numsub,outcome]+1])
}

The decorralted
UMAP
if (nrow(dataframe) < 1000)
{
datasetframe.umap = umap(scale(DEdataframe[1:numsub,varlistc]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After IDeA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[1:numsub,outcome],col=raincolors[DEdataframe[1:numsub,outcome]+1])
}

Univariate
Analysis
Univariate
univarRAW <- uniRankVar(varlist,
paste(outcome,"~1"),
outcome,
dataframe,
rankingTest="AUC")
100 : X297_73 200 : X382_77 300 : X479_57 400 : X629_81 500 :
X796_11
600 : X969_8 700 : X1173_74 800 : X1364_32 900 : X1599_26 1000 :
X1848_42
1100 : X2201_1 1200 : X2498_63 1300 : X2860_34 1400 : X3257_2 1500 :
X3669_6
1600 : X4208_08 1700 : X4836_61 1800 : X5379_65 1900 : X6237_78 2000 :
X7115_25
2100 : X8025_19 2200 : X9106_13 2300 : X10504_79 2400 : X11887_21 2500 :
X13358_42
2600 : X14760_46
univarDe <- uniRankVar(varlistc,
paste(outcome,"~1"),
outcome,
DEdataframe,
rankingTest="AUC",
)
100 : X297_73 200 : X382_77 300 : X479_57 400 : La_X629_81 500 :
X796_11
600 : La_X969_8 700 : X1173_74 800 : X1364_32 900 : X1599_26 1000 :
X1848_42
1100 : X2201_1 1200 : X2498_63 1300 : X2860_34 1400 : X3257_2 1500 :
X3669_6
1600 : X4208_08 1700 : X4836_61 1800 : X5379_65 1900 : La_X6237_78 2000
: X7115_25
2100 : X8025_19 2200 : X9106_13 2300 : X10504_79 2400 : X11887_21 2500 :
X13358_42
2600 : X14760_46
Final Table
univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")
##top variables
topvar <- c(1:length(varlist)) <= TopVariables
tableRaw <- univarRAW$orderframe[topvar,univariate_columns]
pander::pander(tableRaw)
| X301_02 |
1.0971 |
1.288 |
5.780 |
4.428 |
0.37901 |
0.901 |
| X1714_44 |
0.9653 |
1.354 |
2.775 |
2.143 |
0.16574 |
0.876 |
| X1752_66 |
0.4318 |
0.300 |
1.092 |
0.570 |
0.52591 |
0.868 |
| X1539_08 |
0.4536 |
0.386 |
1.205 |
0.790 |
0.08336 |
0.866 |
| X900_35 |
0.7958 |
0.696 |
2.402 |
2.230 |
0.03660 |
0.841 |
| X440_87 |
1.8551 |
1.815 |
4.788 |
3.289 |
0.14184 |
0.839 |
| X1522_71 |
0.5368 |
0.438 |
1.262 |
0.787 |
0.54259 |
0.836 |
| X3325_02 |
39.9174 |
33.638 |
5.890 |
11.627 |
0.00130 |
0.833 |
| X3428_53 |
0.0818 |
0.313 |
0.566 |
1.047 |
0.00325 |
0.829 |
| X256_5 |
2.4015 |
2.773 |
8.994 |
9.942 |
0.00576 |
0.824 |
topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]
pander::pander(finalTable)
| X301_02 |
1.0971 |
1.288 |
5.780 |
4.428 |
0.37901 |
0.901 |
| X1714_44 |
0.9653 |
1.354 |
2.775 |
2.143 |
0.16574 |
0.876 |
| X1752_66 |
0.4318 |
0.300 |
1.092 |
0.570 |
0.52591 |
0.868 |
| X1539_08 |
0.4536 |
0.386 |
1.205 |
0.790 |
0.08336 |
0.866 |
| X900_35 |
0.7958 |
0.696 |
2.402 |
2.230 |
0.03660 |
0.841 |
| X440_87 |
1.8551 |
1.815 |
4.788 |
3.289 |
0.14184 |
0.839 |
| X1522_71 |
0.5368 |
0.438 |
1.262 |
0.787 |
0.54259 |
0.836 |
| X3428_53 |
0.0818 |
0.313 |
0.566 |
1.047 |
0.00325 |
0.829 |
| X256_5 |
2.4015 |
2.773 |
8.994 |
9.942 |
0.00576 |
0.824 |
| X2870_03 |
0.6581 |
0.878 |
1.560 |
1.069 |
0.75629 |
0.821 |
| La_X3679_57 |
0.0881 |
0.213 |
0.261 |
0.213 |
0.25991 |
0.785 |
| La_X5722_3 |
-0.1910 |
0.186 |
0.121 |
0.491 |
0.01869 |
0.770 |
| La_X758_77 |
0.1593 |
0.367 |
-0.235 |
0.576 |
0.33138 |
0.748 |
| La_X263_75 |
6.7179 |
13.119 |
-8.218 |
17.344 |
0.77781 |
0.732 |
| La_X818_6 |
-1.0304 |
2.015 |
0.542 |
3.338 |
0.32543 |
0.729 |
dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")
pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
theCharformulas <- attr(dc,"LatentCharFormulas")
finalTable <- rbind(finalTable,tableRaw[topvar[!(topvar %in% topLAvar)],univariate_columns])
orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- theCharformulas[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]
Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")
finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
| X301_02 |
NA |
1.0971 |
1.288 |
5.780 |
4.428 |
0.37901 |
0.901 |
0.901 |
NA |
| X301_021 |
NA |
1.0971 |
1.288 |
5.780 |
4.428 |
0.37901 |
0.901 |
NA |
NA |
| X1714_44 |
NA |
0.9653 |
1.354 |
2.775 |
2.143 |
0.16574 |
0.876 |
0.876 |
NA |
| X1714_441 |
NA |
0.9653 |
1.354 |
2.775 |
2.143 |
0.16574 |
0.876 |
NA |
NA |
| X1752_66 |
NA |
0.4318 |
0.300 |
1.092 |
0.570 |
0.52591 |
0.868 |
0.868 |
NA |
| X1752_661 |
NA |
0.4318 |
0.300 |
1.092 |
0.570 |
0.52591 |
0.868 |
NA |
NA |
| X1539_08 |
NA |
0.4536 |
0.386 |
1.205 |
0.790 |
0.08336 |
0.866 |
0.866 |
NA |
| X1539_081 |
NA |
0.4536 |
0.386 |
1.205 |
0.790 |
0.08336 |
0.866 |
NA |
NA |
| X900_35 |
NA |
0.7958 |
0.696 |
2.402 |
2.230 |
0.03660 |
0.841 |
0.841 |
NA |
| X900_351 |
NA |
0.7958 |
0.696 |
2.402 |
2.230 |
0.03660 |
0.841 |
NA |
NA |
| X440_87 |
NA |
1.8551 |
1.815 |
4.788 |
3.289 |
0.14184 |
0.839 |
0.839 |
NA |
| X440_871 |
NA |
1.8551 |
1.815 |
4.788 |
3.289 |
0.14184 |
0.839 |
NA |
NA |
| X1522_71 |
NA |
0.5368 |
0.438 |
1.262 |
0.787 |
0.54259 |
0.836 |
0.836 |
NA |
| X1522_711 |
NA |
0.5368 |
0.438 |
1.262 |
0.787 |
0.54259 |
0.836 |
NA |
NA |
| X3325_02 |
NA |
39.9174 |
33.638 |
5.890 |
11.627 |
0.00130 |
0.833 |
0.833 |
NA |
| X3428_53 |
NA |
0.0818 |
0.313 |
0.566 |
1.047 |
0.00325 |
0.829 |
0.829 |
NA |
| X3428_531 |
NA |
0.0818 |
0.313 |
0.566 |
1.047 |
0.00325 |
0.829 |
NA |
NA |
| X256_5 |
NA |
2.4015 |
2.773 |
8.994 |
9.942 |
0.00576 |
0.824 |
0.824 |
3 |
| X256_51 |
NA |
2.4015 |
2.773 |
8.994 |
9.942 |
0.00576 |
0.824 |
NA |
NA |
| X2870_03 |
NA |
0.6581 |
0.878 |
1.560 |
1.069 |
0.75629 |
0.821 |
0.821 |
NA |
| La_X3679_57 |
+ X3679_57 - (2.398)X7409_15 |
0.0881 |
0.213 |
0.261 |
0.213 |
0.25991 |
0.785 |
0.801 |
-1 |
| La_X5722_3 |
- (0.870)X2962_99 + X5722_3 |
-0.1910 |
0.186 |
0.121 |
0.491 |
0.01869 |
0.770 |
0.662 |
-1 |
| La_X758_77 |
- (0.332)X570_46 + X758_77 |
0.1593 |
0.367 |
-0.235 |
0.576 |
0.33138 |
0.748 |
0.585 |
-1 |
| La_X263_75 |
+ X263_75 - (0.593)X281_96 |
6.7179 |
13.119 |
-8.218 |
17.344 |
0.77781 |
0.732 |
0.565 |
-1 |
| La_X818_6 |
- (1.127)X547_98 + (0.996)X570_46 + X818_6 |
-1.0304 |
2.015 |
0.542 |
3.338 |
0.32543 |
0.729 |
0.586 |
1 |
Comparing IDeA vs
PCA vs EFA
PCA
featuresnames <- colnames(dataframe)[colnames(dataframe) != outcome]
pc <- prcomp(dataframe[,iscontinous],center = TRUE,scale. = TRUE) #principal components
predPCA <- predict(pc,dataframe[,iscontinous])
PCAdataframe <- as.data.frame(cbind(predPCA,dataframe[,!iscontinous]))
colnames(PCAdataframe) <- c(colnames(predPCA),colnames(dataframe)[!iscontinous])
#plot(PCAdataframe[,colnames(PCAdataframe)!=outcome],col=dataframe[,outcome],cex=0.65,cex.lab=0.5,cex.axis=0.75,cex.sub=0.5,cex.main=0.75)
#pander::pander(pc$rotation)
PCACor <- cor(PCAdataframe[,colnames(PCAdataframe) != outcome])
gplots::heatmap.2(abs(PCACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "PCA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")

EFA
EFAdataframe <- dataframeScaled
if (length(iscontinous) < 2000)
{
topred <- min(length(iscontinous),nrow(dataframeScaled),ncol(predPCA)/2)
if (topred < 2) topred <- 2
uls <- fa(dataframeScaled[,iscontinous],nfactors=topred,rotate="varimax",warnings=FALSE) # EFA analysis
predEFA <- predict(uls,dataframeScaled[,iscontinous])
EFAdataframe <- as.data.frame(cbind(predEFA,dataframeScaled[,!iscontinous]))
colnames(EFAdataframe) <- c(colnames(predEFA),colnames(dataframeScaled)[!iscontinous])
EFACor <- cor(EFAdataframe[,colnames(EFAdataframe) != outcome])
gplots::heatmap.2(abs(EFACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "EFA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
}
Effect on CAR
modeling
par(op)
par(xpd = TRUE)
dataframe[,outcome] <- factor(dataframe[,outcome])
rawmodel <- rpart(paste(outcome,"~."),dataframe,control=rpart.control(maxdepth=3))
pr <- predict(rawmodel,dataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(rawmodel,main="Raw",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(rawmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,dataframe[,outcome]==0))
}

pander::pander(table(dataframe[,outcome],pr))
pander::pander(ptab$detail[c(5,3,4,6),])
| 5 |
diag.ac |
0.932 |
0.878 |
0.967 |
| 3 |
se |
0.963 |
0.909 |
0.990 |
| 4 |
sp |
0.838 |
0.680 |
0.938 |
| 6 |
diag.or |
135.625 |
35.975 |
511.303 |
par(op)
par(xpd = TRUE)
DEdataframe[,outcome] <- factor(DEdataframe[,outcome])
IDeAmodel <- rpart(paste(outcome,"~."),DEdataframe,control=rpart.control(maxdepth=3))
pr <- predict(IDeAmodel,DEdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(IDeAmodel,main="IDeA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(IDeAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,DEdataframe[,outcome]==0))
}

pander::pander(table(DEdataframe[,outcome],pr))
pander::pander(ptab$detail[c(5,3,4,6),])
| 5 |
diag.ac |
0.938 |
0.886 |
0.971 |
| 3 |
se |
0.972 |
0.922 |
0.994 |
| 4 |
sp |
0.838 |
0.680 |
0.938 |
| 6 |
diag.or |
182.556 |
43.143 |
772.462 |
par(op)
par(xpd = TRUE)
PCAdataframe[,outcome] <- factor(PCAdataframe[,outcome])
PCAmodel <- rpart(paste(outcome,"~."),PCAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(PCAmodel,PCAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(PCAmodel,main="PCA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(PCAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,PCAdataframe[,outcome]==0))
}

pander::pander(table(PCAdataframe[,outcome],pr))
pander::pander(ptab$detail[c(5,3,4,6),])
| 5 |
diag.ac |
0.897 |
0.836 |
0.941 |
| 3 |
se |
0.899 |
0.827 |
0.949 |
| 4 |
sp |
0.892 |
0.746 |
0.970 |
| 6 |
diag.or |
73.500 |
21.908 |
246.593 |
par(op)
EFA
EFAdataframe[,outcome] <- factor(EFAdataframe[,outcome])
EFAmodel <- rpart(paste(outcome,"~."),EFAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(EFAmodel,EFAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(EFAmodel,main="EFA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(EFAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,EFAdataframe[,outcome]==0))
}

pander::pander(table(EFAdataframe[,outcome],pr))
pander::pander(ptab$detail[c(5,3,4,6),])
| 5 |
diag.ac |
0.932 |
0.878 |
0.967 |
| 3 |
se |
0.963 |
0.909 |
0.990 |
| 4 |
sp |
0.838 |
0.680 |
0.938 |
| 6 |
diag.or |
135.625 |
35.975 |
511.303 |
par(op)